package cn.hnbjx.prepaid.dao;

import cn.hnbjx.prepaid.pojo.Account;
import org.apache.ibatis.annotations.*;

import java.util.List;
@Mapper
public interface AccountDao {
    @Select("select * from account where openId=#{openId}")
    Account findAccountById(String openId);
    @Insert("insert into account (nickname,head,openId,createTime) values (#{nickname},#{head},#{openId},now())")
    void insert(Account account);
    @Select("select * from account where id=#{id}")
    Account findById(@Param("id") int id);
    @Select("select * from account where nickname like concat('%',#{key},'%') order by id desc")
    List<Account> getAccount(String key);
    @Select("select * from account where audit=2 and city like concat('%',#{key},'%') order by id desc")
    List<Account> findByProvince(String key);
    @Update("update `account` set `flag`=#{flag},`result`=#{result},`audit`=#{audit} where id=#{id}")
    int updateFlag(@Param("result") String result,@Param("flag") Integer flag,@Param("audit") Integer audit,@Param("id") Integer id);
    @Update("update `account` set `username`=#{username},`tel`=#{tel} where openId=#{openid}")
    int updateAuth(@Param("username") String username,@Param("tel") String tel,@Param("openid") String openid);
    @Update("update `account` set  `audit`=1,`name`=#{name},`phone`=#{phone},`city`=#{city},`address`=#{address},`location`=#{location}  where openId=#{openid}")
    int updateUser(@Param("name") String name,@Param("phone") String phone,@Param("city") String city,@Param("address") String address,@Param("location") String location,@Param("openid") String openid);

}